package br.com.ridea.pegadacultural.teste;

import br.com.ridea.pegadacultural.abracts.ApplicationException;
import br.com.ridea.pegadacultural.abracts.GenericDAO;
import br.com.ridea.pegadacultural.dao.PromoterDAOService;
import br.com.ridea.pegadacultural.implementation.PromoterDAOServiceImpl;
import br.com.ridea.pegadacultural.model.Endereco;
import br.com.ridea.pegadacultural.model.Promoter;

public class Teste {
	

	public void inserirPromoter(){
		
		Promoter p = new Promoter();
		p.setAtivo(Boolean.TRUE);
		p.setCpfCnpj("39618873811");
		p.setAdmin(Boolean.TRUE);
		
		Endereco end = new Endereco();
		end.setBairro("joaquim");
		end.setCep("19911415");
		end.setCidade("Ourinhos");
		end.setLogradouro("Rua Expedicionarios");
		end.setNumero("42C");
		end.setComplemento("casa");
		end.setUf("SP");
		end.setLatitude(-14.1212445D);
		end.setLongitude(-54.12154D);
		
		
		p.setEndereco(end);
		
		PromoterDAOService dao = new PromoterDAOServiceImpl();
		try {
			GenericDAO.initTransaction();
			dao.salvar(p);
			GenericDAO.commitTransaction();
		} catch (ApplicationException e) {
			GenericDAO.rollback();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[] args) {
		new Teste().inserirPromoter();
	}

}
